<template>
  <view>
    <text>api测试</text>

    <view>
      <input v-model="echo" placeholder="echo信息" />
      <button @click="sendEcho">发送</button>
    </view>

    <view class="">
      {{ info }}
    </view>

    <view class="">
      <input v-model="loginfo.logType" type="text" placeholder="类型" />
      <input v-model="loginfo.logInfo" type="text" placeholder="内容" />
      <button @click="sentPost">发送post请求</button>
    </view>

    <view class="">
      {{ postinfo }}
    </view>

  </view>
</template>

<script setup>
  import {
    ref
  } from 'vue'
  import {
    api
  } from '../../js/api.js'

  const echo = ref('')
  const info = ref('')

  const sendEcho = () => {
    api.get('/test/echo', {
      echo: echo.value
    }, (data) => {
      info.value = JSON.stringify(data)
    })
  }

  // post测试
  const loginfo = ref({
    "lid": 110,
    "logType": "",
    "logInfo": "",
    "lastupdate": "2020-10-20 10:11:12"
  })

  const postinfo = ref('')

  const sentPost = () => {
    api.post('/test/converter/json', loginfo.value, (data) => {
      postinfo.value = JSON.stringify(data)
    })
  }
</script>

<style>

</style>